/**
 * FileName: DeviceStatusEnum
 * Author: Wb
 * Date: 2025/9/24 11:56
 * Description:
 * History:
 */
package org.test.device.constant;

import lombok.Getter;

/**
 * 〈一句话功能简述〉<br>
 * 〈设备状态枚举〉
 *
 * @author Wb
 * @create 2025/9/24
 * @since 1.0.0
 */
@Getter
public enum DeviceStatusEnum {

    UN_AUTHENTICATED(0, "未认证"),
    AUTHENTICATED(1, "认证"),
    ENABLED(2, "启用"),
    DISABLED(3, "未启用");


    private final Integer code;
    private final String desc;


    DeviceStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * @Author Wb
     * @Description 根据编码获取对应的枚举实例
     * @Date 11:58 2025/9/24
     * @Param code 状态编码
     * @Return 对应的枚举实例，若未找到则返回null
     */
    public static DeviceStatusEnum getByCode(Integer code) {
        for (DeviceStatusEnum status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        return null;
    }
}
